<template>
	<view class="content">
		<view class="title">{{data.title}}</view>
		<view class="time">{{data.createTime}}</view>
		<view v-html="data.content"/>
	</view>
</template>
<script>
	import API from '../../common/api.js';
	export default {
		components: {

		},
		data() {
			return {
				id:0,
				data:{}
			}
		},
		onLoad(option) {
			if(option.type){
				this.data=JSON.parse(uni.getStorageSync('activityData'))
				this.data.content=this.data.content.replace(RegExp(`<img class="wscnph;" style="`, "g"),`<img class="wscnph;" style="margin:10px 0;`)
				this.data.createTime=new Date(this.data.createTime * 1000).format('yyyy-MM-dd')
			}else{
				this.id=option.id
				this.getData()
			}
		},
		methods: {
			async getData(){
				uni.showLoading()
				let json = await API.buildPromotionDetail({
					"targetId": this.id,
					'token':'token'
				});
				if(json.status==200){
					this.data=json.data
					this.data.content=this.data.content.replace(RegExp(`<img class="wscnph;" style="`, "g"),`<img class="wscnph;" style="margin:10px 0;`)
					console.log(this.data.content)
					this.data.createTime=new Date(this.data.createTime * 1000).format('yyyy-MM-dd')
				}else{
					uni.showModal({
						title: '提示',
						content: '加载失败',
						showCancel: false,
					});
				}
				uni.hideLoading()
			},
		}
	}
</script>

<style scoped>
	.content {
		padding:30upx 3% 60upx  3%;
		line-height:60upx;
	}
	.title{
		font-size: 48upx;
	}
	.time{
		font-size: 24upx;
		color: #999999;
		margin-bottom: 70upx;
	}

</style>
